﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using AjaxControlToolkit;
using System.Threading;
using System.Globalization;
using System.Data;

public partial class mysetting : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
        

    }
    
    protected void comps_SelectedIndexChanged(object sender, EventArgs e)
    {
        
       
    }
    protected override void InitializeCulture()
    {
        base.InitializeCulture();
        if (Session["CurrentCulture"] != null)
        {
            string lang = Session["CurrentCulture"].ToString();
            if (lang != null && lang != "")
            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);
                System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat = new System.Globalization.CultureInfo("en-US", false).DateTimeFormat;


            }
        }
    }





    protected void SaveButton_Click(object sender, EventArgs e)
    {
        if (AsyncFileUpload1.HasFile)
        {

            string paths = Server.MapPath(Request.ApplicationPath) + "\\uploads\\" + AsyncFileUpload1.FileName;

            AsyncFileUpload1.SaveAs(paths);
            //AsyncFileUpload1.ClearAllFilesFromPersistedStore();

            List<string> fields = new List<string>();
            ArrayList values = new ArrayList();
            List<string> types = new List<string>();

            fields.Add("company_id");
            types.Add("int");
            values.Add(Session["company_id"].ToString());

            /////////////////////////////
            fields.Add("banner");
            types.Add("string");
            values.Add(AsyncFileUpload1.FileName);


         DataSet ds =    DB.getdata("Select * from companysetting where company_id =" + Session["company_id"].ToString());
         if (ds.Tables[0].Rows.Count > 0)
         {
             fields.Add("theme");
             types.Add("string");
             values.Add(ds.Tables[0].Rows[0]["theme"].ToString());

             DB.UPDATE("companysetting", "int,company_id," + Session["company_id"].ToString(), fields, types, values);
         }
         else
         {
             fields.Add("theme");
             types.Add("string");
             values.Add("");
             DB.INSERT("companysetting", fields, types, values);
         }


         Session["banner"] = null;

        }
    }
}
